package com.lujieni.seatapay.controller;

import com.lujieni.seatapay.dao.PayPOMapper;
import com.lujieni.seatapay.po.PayPO;
import com.lujieni.seataproxy.StoreFeign;
import com.lujieni.seataproxy.dto.PayDTO;
import com.lujieni.seataproxy.dto.StoreDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class PayController {

    @Autowired
    private PayPOMapper payPOMapper;
    @Autowired
    private StoreFeign storeFeign;

    @PostMapping(value = "/addPay")
    public void addPay(@RequestBody PayDTO payDTO) {
        PayPO payPO = new PayPO();
        BeanUtils.copyProperties(payDTO, payPO);
        payPOMapper.insert(payPO); //先本地提交
        StoreDTO storeDTO = new StoreDTO();
        BeanUtils.copyProperties(payDTO, storeDTO);
        storeFeign.addStore(storeDTO);
    }


}
